-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat!: Use omitzero for BypassActors to support handling empty arrays
#3891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
omitzero for BypassActors to support handling empty arrays
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3891 +/- ##
==========================================
- Coverage 92.55% 92.53% -0.03%
==========================================
Files 201 201
Lines 14757 14702 -55
==========================================
- Hits 13659 13604 -55
Misses 897 897
Partials 201 201 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR I see a lot of removed code and a single line change.
Please add tests that demonstrate the difference between using omitempty and omitzero for the BypassActors field.
|
Thanks for the review! @gmlewis sir I've added test cases for Repositories, Organizations, and Enterprise rulesets to demonstrate the omitzero behavior. The tests confirm: Passing nil (zero value) correctly omits the bypass_actors field from the JSON (preserving existing values). Passing an empty slice [] correctly sends "bypass_actors": [] (clearing the values). I also ran the linter and tests locally, and everything is green. |
gmlewis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @maishivamhoo123!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo befor emerging.
|
cc: @stevehipwell - @alexandear - @zyfy29 |
|
@alexandear Sir and @gmlewis Sir, I believe I’ve addressed all the comments and resolved the discussion points in this commit. Could you please review and let me know if I’ve missed anything? Thank you Sir. |
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
|
Thank you, @alexandear! |
BREAKING CHANGE:
UpdateRepositoryRulesetClearBypassActor,UpdateRepositoryRulesetClearBypassActor,UpdateRulesetClearBypassActor, andUpdateRulesetNoBypassActorhave been removed as they are no longer needed.Fixes #3859
With the release of Go 1.24, this PR updates the
RepositoryRulesetstruct to use theomitzerotag. This allows the API to differentiate between anilslice (do not update) and an empty slice (clear values) without needing separate workaround structs.Changes
RepositoryRuleset.BypassActorsto useomitzeroinstead ofomitempty.rulesetNoOmitBypassActorsrulesetClearBypassActorsUpdateRulesetcan now handle clearing actors via an empty slice):UpdateRulesetClearBypassActorUpdateRulesetNoBypassActorThis PR relies on the recent linter updates merged to support the
omitzerotag._